﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class FlowStatusBill : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            lblBackUrl.Text = Request.UrlReferrer.ToString();
            string flowId = Request.QueryString["flowId"].ToString();
            BindToDataStatusBill(flowId);
            BindFlowMsg(flowId);
            
        }
    }
    protected void BindToDataStatusBill(string flowId)
    {
        string currentYear = flowId.Substring(4, 4);
        string tabName = "LCBZ" + currentYear;
        DBOperation DBO = new DBOperation();
        string sqlstring = "select * from " + tabName + " where TRUEFLOWID='" + flowId + "' order by SEQ ASC";
        DataSet ds = DBO.GetDataSet(sqlstring, "TEMP");
        rpFSBill.DataSource = ds.Tables["TEMP"].DefaultView;
        rpFSBill.DataBind();
        lblFlowId.Text = flowId;
    }
    protected void BindFlowMsg(string flowId)
    {
        string dataID=flowId.Substring(2);
        string currentYear = flowId.Substring(4, 4);
        string dataPrefix=flowId.Substring(2,2);
        Hashtable tabHt=BasicClass.GetTabPrefixAndDataIDHashTab();
        string tablePrefix=tabHt[dataPrefix].ToString();
        tablePrefix = "DATA";
        string tableName = tablePrefix + currentYear;
        string sqlString = "select * from " + tableName + " where dataID='" + dataID + "'";
        DBOperation DBO = new DBOperation();
        SqlDataReader sdr = DBO.GetDataReader(sqlString);
        if (sdr.Read())
        {
            lblTitle.Text = sdr["TITLE"].ToString();
            lblUpDep.Text = BasicClass.GetDepNameByDepID(sdr["DEPID"].ToString());
            lblUpUser.Text = BasicClass.GetTrueNameByUserName(sdr["USERNAME"].ToString());
        }
        sdr.Close();
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        string refURL = "MessageInfo.aspx";

        refURL = lblBackUrl.Text;
        if (refURL == "" || refURL == null || refURL == "MenuDir.aspx")
        {
            refURL = "MessageInfo.aspx";
        }
        Response.Redirect(refURL);
    }
}
